<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>币种新增</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/global.css" media="all">
    <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/table.css"/>
    <link rel="stylesheet" href="/plugins/layui/css/public.css" media="all" />
    <style>
        .layui-form-label {
            width: 10%;
        }
        .layui-input-block {
            margin-left: 13%;
        }
        .required-field {
            color: red;
            margin-right: 2px;
            font-size: 15px;
            text-align: center;
        }
        img {
            width: 110px;
            height: 110px;
        }
        .layui-upload-list {
            margin-left: 13%;
        }

    </style>
</head>
<body>
<div style="margin: 15px;">
<form class="layui-form" id="layui-form" action="/manage/currency/inscurr" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label layui-required-tip">中文名称：</label>
        <div class="layui-input-block">
            <input type="text" id="coinNameCn" name="coinNameCn" lay-verify="required" placeholder="请输入币种名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-required-tip">英文名称：</label>
        <div class="layui-input-block">
            <input type="text" id="coinNameEn" name="coinNameEn" lay-verify="required" placeholder="请输入币种名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-required-tip">货币简称：</label>
        <div class="layui-input-block">
            <input type="text" id="symbol" name="symbol" lay-verify="required" placeholder="请输入货币简称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属行业：</label>
        <div class="layui-input-block">
            <select multiple lay-search name="industryIndustryIds" id="industryIndustryIds">
                <option value="">所属行业</option>
                <#if industList??>
                    <#list industList as indust>
                        <option value="${indust.id}">${indust.industryName!}</option>
                    </#list>
                </#if>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属概念：</label>
        <div class="layui-input-block">
            <select  multiple lay-search name="industryCategoryIds" id="industryCategoryIds">
                <option value="">所属概念</option>
                <#if conceptList??>
                    <#list conceptList as concept>
                        <option value="${concept.id}">${concept.conceptCategoryName!}</option>
                    </#list>
                </#if>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-required-tip">cmcId：</label>
        <div class="layui-input-block">
            <input type="text" id="cmcId" name="cmcId" lay-verify="required" placeholder="请输入cmcId" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-required-tip">固定换手率：</label>
        <div class="layui-input-block">
            <input type="text" id="fixedTurnoverRate" name="fixedTurnoverRate" lay-verify="required|number" placeholder="请输入固定换手率" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-required-tip">权重：</label>
        <div class="layui-input-block">
            <input type="text" id="fixedWeights" name="fixedWeights" lay-verify="required|number" placeholder="请输入固定权重" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label layui-required-tip">图标：</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="test">
                <i class="layui-icon">&#xe67c;</i>图标
            </button>
        </div>
        <div class="layui-upload-list">
            <img class="layui-upload-img" id="logoImg">
            <input type="hidden"  name="imageUrl" id="imageUrl" class="layui-input"/>
            <p id="logoText"></p>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-block" id="enableFlag" >
            <input type="radio" name="enableFlag" value="1" title="启用" >
            <input type="radio" name="enableFlag" value="0" title="停用" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">货币诊断：</label>
        <div class="layui-input-block" id="currencyDiagnosisFlag" >
            <input type="radio" name="currencyDiagnosisFlag" value="1" title="支持">
            <input type="radio" name="currencyDiagnosisFlag" value="0" title="不支持" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">权重货币：</label>
        <div class="layui-input-block" id="weights" >
            <input type="radio" name="weights" value="1" title="是" >
            <input type="radio" name="weights" value="0" title="否" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">法币：</label>
        <div class="layui-input-block" id="frenchCurrency" >
            <input type="radio" name="frenchCurrency" value="1" title="支持" >
            <input type="radio" name="frenchCurrency" value="0" title="不支持" checked>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="save">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary" >重置</button>
            <button type="button" class="layui-btn layui-btn-primary" onclick="javascript:history.back();" >返回</button>
        </div>
    </div>
</form>
</div>
<script type="text/javascript" src="/plugins/layui/layui.js"></script>
<script type="text/javascript" src="/js/global-config.js"></script>
<script>
    layui.config({
        base: '/js/' //假设这是你存放拓展模块的根目录
    }).extend({ //设定模块别名
        mymod: 'selectMultiple' //如果 mymod.js 是在根目录，也可以不用设定别名
    });

    layui.use(['layedit', 'laydate','selectMultiple'], function() {
        var form = layui.selectMultiple;
        var $ = layui.jquery;
        var layer = layui.layer; //获取当前窗口的layer对象
        var laydate = layui.laydate;//日期

        form.render();

        layer.ready(function () {
            var $layer = $('#layui-form');
            //监听提交监听提交
            form.on('submit(save)', function(data){
                if($("#imageUrl").val()==""){
                    layer.msg("请上传图片", { icon: 5, shift: 6 });
                    return false;
                }
/*                if(data.field.frenchCurrency == '1'){
                    if(data.field.industryCategoryIds == null){
                        layer.msg("法币概念不能为空", { icon: 5, shift: 6 });
                    }
                    if(data.field.industryIndustryIds == null){
                        layer.msg("法币行业不能为空", { icon: 5, shift: 6 });
                    }
                }*/
                layer.confirm('确认要提交吗？', {
                    btn : [ '确定', '取消' ]//按钮
                }, function(index) {
                    $layer.submit();
                    layer.close(index);
                });
                return false;
            });
        })
    });

    layui.use('upload', function(){
        var upload = layui.upload;
        var $ = layui.jquery
        //执行实例
        var uploadlogo = upload.render({
            url: '/manage/upload/uploadFile',
            elem: '#test', //指定原始元素，默认直接查找class="layui-upload-file"
            size: 1000,
            before: function(obj) {
                layer.load();
            },
            done: function(res){
                //上传完毕回调
                $('#logoImg').attr('src', res.data["imgUrl"]); //图片链接（base64）
                $('#imageUrl').val(res.data["key"]);
                layer.closeAll('loading');
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });
</script>
</body>
</html>